home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
bioinformatics.org
/
bioinformatics.org_software.tar
/
www.bioinformatics.org
/
download
/
ecell2
/
ecell220setup.exe
/
{app}
/
standard
/
SRCJ
/
ECell2Interface.java
< prev
next >
Wrap
Text File
|
2002-05-13
|
4KB
|
201 lines
/**
* title: ECell2Interface class (ECell2Interface.java)<p>
* description : superclass for ECell2 interface windows <p>
* Copyright (C) 1996-2001 Keio University <p>
* Copyright (C) 1998-2001 Japan Science and Technology Corporation (JST)<p>
* GNU General Public Licence <p>
* Division: Mitui Knowledge Industry Co. Ltd. Bioscience division <p>
* Version : $Id: ECell2Interface.java,v 1.3 2002/05/13 00:23:04 ota Exp $ <p>
*/
package ecell;
import java.awt.event.*;
import javax.swing.JFrame;
import java.awt.*;
abstract class ECell2Interface extends JFrame implements ActionListener, AccessListener
{
/**
* instance of MainWindow
*/
public MainWindow window = null;
private boolean bRunning = false;
public static Rectangle geometry = null;
public static Dimension dimScreen = null;
public static String name = null;
/**
* Constructor
* @param window MainWindow
*/
ECell2Interface( MainWindow window )
{
this.window = window;
if( ECell2Interface.dimScreen == null )
{
ECell2Interface.dimScreen = Toolkit.getDefaultToolkit().getScreenSize();
}
}
/**
* initialize window components
*/
abstract protected void jbInit();
/**
* invoke when window has closed
*/
abstract protected void exit_actionPerformed();
/**
* event listener for update self
* @param win MainWindow
*/
abstract public void accessJni( MainWindow win );
/**
* event listener for ActionListener
* @param e ActionEvent
*/
abstract public void actionPerformed( ActionEvent e );
/**
* confirming exit when the window is closed.
* @return boolean
*/
protected boolean confirmExit()
{
return true;
}
/**
* exit when the window is closed.
* @param e WindowEvent
* @return void
*/
protected void processWindowEvent( WindowEvent e )
{
super.processWindowEvent(e);
if ( e.getID() == WindowEvent.WINDOW_CLOSING )
{
if( confirmExit() )
{
exit_actionPerformed();
}
}
}
public boolean getRunningFlag()
{
return bRunning;
}
public void setRunningFlag( boolean flag )
{
this.bRunning = flag;
}
public static final void setGeometry( Rectangle geo )
{
//synchronized( geometry )
{
ECell2Interface.geometry = geo;
}
}
public static final Rectangle getGeometry()
{
Rectangle geo = ECell2Interface.geometry;
ECell2Interface.geometry = null;
return geo;
}
public static final void setInterfaceName( String name )
{
ECell2Interface.name = name;
}
public static final String getInterfaceName()
{
String ret = ECell2Interface.name;
ECell2Interface.name = null;
return ret;
}
protected void setSizeAndLocation( Dimension sz, Point pt )
{
Rectangle geo = ECell2Interface.getGeometry();
if( geo != null )
{
Dimension screen = ECell2Interface.dimScreen;
//System.out.println( "Screen size:" + screen );
if( screen.width < geo.width )
{
geo.width = screen.width;
}
if( screen.height < geo.height )
{
geo.height = screen.height;
}
if( geo.x == Integer.MIN_VALUE )
{
geo.x = screen.width - geo.width;
}
else
{
geo.x = (geo.x < 0)? (screen.width + geo.x) : geo.x;
if( screen.width < (geo.x + geo.width) )
{
geo.x = screen.width - geo.width;
}
else if( geo.x < 0 )
{
geo.x = 0;
}
}
if( geo.y == Integer.MIN_VALUE )
{
geo.y = screen.height - geo.height;
}
else
{
geo.y = (geo.y < 0)? (screen.height + geo.y) : geo.y;
if( screen.height < (geo.y + geo.height) )
{
geo.y = screen.height - geo.height;
}
else if( geo.y < 0 )
{
geo.y = 0;
}
}
//System.out.println( "size:" + geo.getSize() + "/location:" + geo.getLocation() );
this.setSize( geo.getSize() );
this.setLocation( geo.getLocation() );
}
else
{
this.setSize( sz );
this.setLocation( pt );
}
}
}